import { AntdModalProps } from "@/hooks/useAntdModal"
import { saveReleasePlan } from "@/service/deliver"
import { DatePicker, Form, Input, Modal } from "antd"

const SaveReleasePlan = ({ form, closeModal, refresh, modalProps }: AntdModalProps) => {
  const onOk = async () => {
    let data = await form.validateFields()
    data.startDate = data.date[0].format('YYYY-MM-DD HH:mm:ss');
    data.endDate = data.date[1].format('YYYY-MM-DD HH:mm:ss');
    delete data.date
    await saveReleasePlan(data)
    refresh()
    closeModal()
  }
  return <Modal  {...modalProps} onOk={onOk}>
    <Form labelCol={{ span: 6 }} form={form}>
    <Form.Item hidden name='id' >
        <Input />
      </Form.Item>
      <Form.Item label='发布计划名称' name='name' rules={[{
        required: true,
        message: '发布计划名称'
      }]}>
        <Input />
      </Form.Item>

      <Form.Item label='项目版本' name='version' rules={[{
        required: true,
        message: '项目版本'
      }]}>
        <Input />
      </Form.Item>
      <Form.Item label='计划周期' name='date' rules={[{
        required: true,
        message: '计划周期'
      }]}>
        <DatePicker.RangePicker />
      </Form.Item>
    </Form>
  </Modal>
}
export default SaveReleasePlan